<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BScreenAddServiceApp
 *
 * @author jianfeng
 */
class BScreenAddServiceApp extends BUIScreen {

    //put your code here

    public function render($data = null) {
        //    $controller = Yii::app()->getController();
        //$controller->render('addServiceApp');     
        //$service = $this->getUINode()->getActiveService();        

        $isRenderInitialView = true;      

        //   $form = $this->getFormByMeta('AddServiceApplication', $fStyle);
        $addForm = $this->getFormByMeta('AddServiceApplication', $this, array('model' => 'CreateServiceFormModel'));
        
        if ($addForm->submitted('next') && $addForm->validate()) {
            
        }
        
        if ($addForm->submitted('complete') && $addForm->validate()) {
            $this->gotoScreen('BScreenCreateServiceSummary', $data);
        }

        if ($isRenderInitialView)
        {
            $data['form'] = $addForm;
            $this->renderView('showOneForm',$data);
        }
    }

    public function getServiceAppsData() {

        $service = $this->getUINode()->getTransitVariable(BScreenCreateServiceMeta::TRANSIT_VARIABLE_NEWSERVICE);

        $db = $service->getServiceEngine()->getDbAdapter();

        $apps = $db->getServiceApps($service->getId());

        $data = array();

        foreach ($apps as $app) {
            if ($app->isVisible($service)) {
                $data[$app->getId()] = $app->getName();
            }
        }
        return $data;
    }

}

?>
